//
// Created by 17775 on 2024/11/4.
//

#include "Single_HistogramUI.h"

Single_HistogramUI::Single_HistogramUI(QWidget *parent) : HistogramBase(parent) {
    setTitleName("Single Histogram");
//    setDrag();
}

void Single_HistogramUI::processData(std::shared_ptr<PowerProfileData<QVector<double>>> &data) {
    auto a = data->diameterData();
    auto minIt = std::min_element(a.begin(), a.end());
    auto maxIt = std::max_element(a.begin(), a.end());
    auto firstValue = a[0];
    auto secondValue = a[1];
    auto difference = secondValue - firstValue;
    setXRange(*minIt, *maxIt);
    setWidth(difference);
    getHistogram()->setData(a, data->powerData());
    QMetaObject::invokeMethod(getCustomPlot(), "replot", Qt::QueuedConnection);
}

Single_HistogramUI::~Single_HistogramUI() = default;